#define  _CRT_SECURE_NO_WARNINGS

class Solution {
public:
    bool func(string& s, int left, int right)
    {
        while (left < right)
        {
            if (s[left] != s[right])
                return false;
            else
            {
                left++;
                right--;
            }
        }
        return true;
    }
    bool validPalindrome(string s) {
        int left = 0, right = s.size() - 1;
        while (left < right)
        {
            if (s[left] == s[right])
            {
                left++;
                right--;
            }
            else
            {
                return func(s, left + 1, right) || func(s, left, right - 1);
            }
        }
        return true;
    }
};